package http

import (
	"github.com/gin-gonic/gin"
)

type Gin struct {
	C *gin.Context
}

type Response struct {
	Code int         `json:"code"` // 200代表成功;其他代表失败
	Msg  string      `json:"msg"`  // 错误信息,成功时为"ok"
	Data interface{} `json:"data"` // 返回数据
}

// Response setting gin.JSON
func (g *Gin) Response(code int, msg string, data interface{}) {
	g.C.JSON(200, Response{
		Code: code,
		Msg:  msg,
		Data: data,
	})
}
